home *** CD-ROM | disk | FTP | other *** search
- /*
- File: PlatfMem.h
-
- Contains: Platform layer interfaces
-
- Owned by: Jens Alfke
-
- Copyright: © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <13> 10/14/95 TJ Updated decleration of SOMPrintf to new Mac
- SOM decleration
- <12> 6/1/95 jpa Restored <11>: Changed def of highest
- possible address, for VM compatibility
- [1249619]
- <11> 5/17/95 TJ Backed out changes from previous checkin.
- <9> 5/4/95 jpa Added MinFreeSpace consts [1235657]
- <8> 9/29/94 RA 1189812: Mods for 68K build.
- <7> 9/14/94 jpa Eliminated dependencies on rest of OpenDoc.
- [1186692]
- <6> 8/17/94 jpa Improved assertion and print-string macros.
- <5> 8/8/94 jpa #ifdef OD_DEBUG --> #if ODDebug
- <4> 6/22/94 NP Cast for PPCC.
- <3> 6/21/94 jpa Fixed PLATFORM... macros to compile w/o
- warnings from CodeWarrior.
- <2> 6/10/94 MB Make it build
- <1> 6/9/94 MB first checked in
- <2> 5/9/94 MB #1162181: Changes necessary to install MMM.
- <1> 4/29/94 MB first checked in
- To Do:
- In Progress:
-
- */
-
- #ifndef _PLATFMEM_
- #define _PLATFMEM_
-
- #ifndef _MEMCNFIG_
- #include "MemCnfig.h"
- #endif
-
- #ifndef _MEMMGR_
- #include <MemMgr.h>
- #endif
-
- #include <stddef.h>
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
-
- //========================================================================================
- // Defines
- //========================================================================================
-
- #ifndef __MWERKS__
- #define _FIL_ "" /* MPW puts entire pathnames in; yuk! */
- #else
- #define _FIL_ __FILE__
- #endif
-
- #define MM_ASSERT(condition) \
- if(!MM_DEBUG || (condition)) ; else MM_ASSERT_FAILED( #condition, _FIL_ )
-
- #define MM_WARN \
- if(!MM_DEBUG) ; else MM_SHOW_WARNING
-
- #define MM_PRINTING 0 // Set to 1 to enable MM_PRINT
-
- #define MM_PRINT if( !MM_PRINTING ) ; else somPrintf
-
-
- //========================================================================================
- // Types
- //========================================================================================
-
- typedef unsigned long MMULong;
-
- #ifdef __xlC
- typedef unsigned long SIZE_T;
- #else
- typedef size_t SIZE_T;
- #endif
-
-
-
- //========================================================================================
- // Constants
- //========================================================================================
-
- const MMBoolean kMMFalse = 0;
- const MMBoolean kMMTrue = 1;
-
- #define kMMNULL (0)
-
- const size_t kPlatformMinFreeSpace = 64 * 1024; // Leave this much free
- const size_t kPlatformMinContigSpace = 32 * 1024; // Leave this size block available
-
-
- //========================================================================================
- // Global function declarations
- //========================================================================================
-
- /* Adkins -- removed const from first param to somPrintf -- it was never const */
- extern "C" int somPrintf (const char * fmt, ...); // From <somapi.h>
-
- void PlatformZapMem( void *start, size_t size, MMULong value );
- void *PlatformAllocateBlock(size_t size, MMHeapLocation);
- void PlatformFreeBlock(void *ptr);
-
- void MM_ASSERT_FAILED(const char *cond, const char *fil);
- void MM_SHOW_WARNING(const char *msg, ...);
-
- //----------------------------------------------------------------------------------------
- // PlatformCopyMemory
- //----------------------------------------------------------------------------------------
-
- inline void PlatformCopyMemory(void *source, void *destination, size_t length)
- {
- BlockMoveData(source, destination, (Size) length);
- }
-
- #if MM_DEBUG
-
- #define LOWEST_POSSIBLE_ADDRESS() ((void*) &SystemZone()->heapData)
- #define HIGHEST_POSSIBLE_ADDRESS() ((void*) gTotalMemory)
-
- extern size_t gTotalMemory;
-
- #endif
-
- #endif
-